<?php
	class UserpushController extends IndexController {
		public function init()
	    {
			parent::init();
	        $this->utl            = Yaf_Registry::get("utl");
	        $this->DetailsModel   = new DetailsModel();
	        $this->UserModel      = new UserModel();
	    }

		public function listAction() 
		{
			//var_dump( $_POST);
			
			$pushUserAboutInfo = array();
			$user_info         = $this->UserModel->getUserInfo();
        	//$site_info         = $this->WebsiteModel->selectSites();
        	$pushUser          = $this->DetailsModel->selectPushUser();
        	$pushTime          = $this->DetailsModel->selectPushTime();
        	
        	if ($this->getRequest()->isPost()) {
            	$post = $this->getRequest()->getPost();
            	$pushUserInfo      = $this->DetailsModel->selectPushTimeInfo($pushUser,$pushTime,$_POST);
            	
            	//var_dump($pushUserInfo);
        	}
        	else{
        		$pushUserInfo      = $this->DetailsModel->selectPushInfo($pushUser,$pushTime);
        	}
        	foreach ($pushUserInfo as $k => $v) {
                    $pushUserAboutInfo[$k]['count']      = $v[0]['count'];
                    $pushUserAboutInfo[$k]['push_time']  = date('Y-m-d', (int) $v[0]['create_time']);
                    foreach ($user_info  AS $ks => $vs)
                    {
                        if ($v[0]['user_id'] === $vs['user_id'])
                        {
                            $pushUserAboutInfo[$k]['user_name'] = $vs['realname'];break;
                        }
                    }
                    
        	}
        	$str = "";
        	foreach ($pushUserAboutInfo as $key => $value) {
        		$str .= '{y:"'.$value['user_name'].'",a:"'. $value['count'] .'"},';
        	}
       
        	
        	$this->getView()->assign("pushUserAboutInfo",$str);
        	$this->getView()->assign("time_date",$_POST['push_time_input']);
        	
        	//var_dump($str);
        	
        	
	       
		}
	}
?>
